package com.dongdong.tbbrandService.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.mapper.TbTypeTemplateMapper;
import com.dongdong.pojo.PageBean;
import com.dongdong.pojo.TbSpecification;
import com.dongdong.pojo.TbSpecificationOption;
import com.dongdong.pojo.TbTypeTemplate;
import com.dongdong.service.TbTypeTemplateService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class TbTypeTemplateServiceImpl implements TbTypeTemplateService {
    @Autowired
    private TbTypeTemplateMapper tbTypeTemplateMapper;

    @Override
    public PageBean<TbTypeTemplate> getInfo(String name,Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
//        List<TbTypeTemplate> list = tbTypeTemplateMapper.selectByExample(null);
        List<TbTypeTemplate> list = tbTypeTemplateMapper.getInfo(name);
        PageInfo<TbTypeTemplate> pageInfo = new PageInfo(list);
        return new PageBean<TbTypeTemplate>(pageInfo.getTotal(),pageInfo.getPages(),pageInfo.getStartRow(),pageInfo.getPageSize(),pageInfo.getPageNum(),pageInfo.getList());
    }

    @Override
    public void save(TbTypeTemplate tbTypeTemplate) {
        tbTypeTemplateMapper.insertSelective(tbTypeTemplate);
    }

    @Override
    public void deleteAll(Long[] ids) {
        tbTypeTemplateMapper.deleteAll(ids);
    }

    @Override
    public TbTypeTemplate toUpdate(Long id) {
        return tbTypeTemplateMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(TbTypeTemplate tbTypeTemplate) {
        tbTypeTemplateMapper.updateByPrimaryKeySelective(tbTypeTemplate);
    }

    @Override
    public List<TbTypeTemplate> getShowId() {
        return tbTypeTemplateMapper.selectByExample(null);
    }

    @Override
    public  TbTypeTemplate getTypeId(Long typeId) {

        return tbTypeTemplateMapper.selectByPrimaryKey(typeId);
    }
}
